/**
 * 
 */
package com.aq.actions;

/**
 * @author shl
 *
 */
import java.util.Collection;

import org.apache.commons.lang.StringUtils;

import com.aq.model.AqNews;
import com.aq.service.INewsService;
import com.hs.common.page.PageParam;
import com.hs.common.page.PageUtil;
import com.hs.core.action.AbstractAction;

public class NewsAction extends AbstractAction {
    
    private INewsService newsService;  
    private AqNews news; 
    
    protected Collection availableItems;
    protected String pageStr;
    protected String content;
    protected PageUtil pageUtil; 
    protected String queryName;
    protected String queryValue;
    protected String searchName;
    protected String searchValue;
    protected String queryMap;
    protected Long newsid;
    
    public String list() throws Exception {
    	
    	PageParam pageParam = new PageParam(this.getHttpServletRequest(),"listNews.action");
		String hql = " from AqNews where 1=1";
		pageParam.setSearchSql(hql);
		pageUtil = newsService.getNewsList(pageParam);
		availableItems = pageUtil.getPageList();
		pageStr = pageUtil.getPageStr();
		this.getHttpServletRequest().setAttribute("dataList", availableItems);
        return SUCCESS;         
    }
    
    public String load() throws Exception {
    	String newsid = this.getHttpServletRequest().getParameter("newsid");
    	if(StringUtils.isNotEmpty(newsid)){
    		setNewsid(new Long(newsid));
    		this.news = (AqNews)newsService.findByID(AqNews.class, this.getNewsid());
    		setContent(this.news.getContent() == null?"":this.news.getContent());
    	} 
    	
        return SUCCESS;
    } 
    public String save() throws Exception {  
    	if(null != news){ 
    		newsService.saveObject(news); 
    	}
        return SUCCESS;
    }
    
    public String delete() throws Exception {
       
        return SUCCESS;
    }     
    public Collection getAvailableItems() {
        return availableItems;
    }

    public String getQueryName() {
        return queryName;
    }

    public void setQueryName(String queryName) {
        this.queryName = queryName;
    }

    public String getQueryValue() {
        return queryValue;
    }

    public void setQueryValue(String queryValue) {
        this.queryValue = queryValue;
    }
    
    public String getSearchName() {
        return searchName;
    }

    public void setSearchName(String searchName) {
        this.searchName = searchName;
    }

    public String getSearchValue() {
        return searchValue;
    }

    public void setSearchValue(String searchValue) {
        this.searchValue = searchValue;
    }
    
    public String getQueryMap() {
        return queryMap;
    }

    public void setQueryMap(String queryMap) {
        this.queryMap = queryMap;
    }

	public INewsService getNewsService() {
		return newsService;
	}

	public void setNewsService(INewsService newsService) {
		this.newsService = newsService;
	}

	public AqNews getNews() {
		return news;
	}

	public void setNews(AqNews news) {
		this.news = news;
	}

	public PageUtil getPageUtil() {
		return pageUtil;
	}

	public void setPageUtil(PageUtil pageUtil) {
		this.pageUtil = pageUtil;
	}

	public void setAvailableItems(Collection availableItems) {
		this.availableItems = availableItems;
	}

	public String getPageStr() {
		return pageStr;
	}

	public void setPageStr(String pageStr) {
		this.pageStr = pageStr;
	}

	public Long getNewsid() {
		return newsid;
	}

	public void setNewsid(Long newsid) {
		this.newsid = newsid;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
    
    
}
